﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class D03_Player : MonoBehaviour
{
    public float speed = 5f;
    public float rSpeed = 180;//旋转速度
    public GameObject bulletPrefab;
    private Transform firePoint;
    private void Start()
    {
        firePoint = transform.Find("FirePoint");
    }
    private void Update()
    {
        float h = Input.GetAxisRaw("Horizontal");
        float v = Input.GetAxisRaw("Vertical");

        //移动
        transform.Translate(Vector3.forward * Time.deltaTime * v * speed);
        //旋转
        transform.Rotate(Vector3.up * Time.deltaTime * h * rSpeed);

        //发射子弹
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
        }
    }
}